package edu.bbu.commonproject.backend.db.services;

import java.util.ArrayList;

import edu.bbu.commonproject.backend.db.exceptions.DataBaseErrorException;
import edu.bbu.commonproject.backend.db.exceptions.DirectoryConflictException;
import edu.bbu.commonproject.backend.db.exceptions.UserConflictException;
import edu.bbu.commonproject.backend.db.model.DBDirectory;

/**
 * Interface that all DirectoryDAOService must support. 
 */
public interface DirectoryDAOServices
{
	/**
	 * Create a new directory.
	 * @param directory the directory model.
	 * @throws DirectoryConflictException if the directory already exist.
	 * @throws DataBaseErrorException if error occured in database.
	 */
	public abstract void createDirectory(DBDirectory directory) throws DirectoryConflictException, DataBaseErrorException;
	
	/**
	 * Deleteing a directory.
	 * @param directory the directory model.
	 * @throws DirectoryConflictException if the directory already exist.
	 * @throws DataBaseErrorException if error occured in database.
	 */
	public abstract void deleteDirectory(DBDirectory directory) throws DirectoryConflictException, DataBaseErrorException;
	
	/**
	 * Getting the directoryes from directory.
	 * @param directory the directory model.
	 * @return the list of directoryes.
	 * @throws DataBaseErrorException if error occured in database.
	 */
	public abstract ArrayList<String> getDirectoriesFromDirectory(DBDirectory directory) throws DataBaseErrorException;
	
	/**
	 * Getting the base directory.
	 * @param owner the owner of the directory.
	 * @return the base directory model.
	 */
	public abstract DBDirectory getBaseDirectory(String owner);
	
	/**
	 * Check if a directory exist. 
	 * @param directory the directory model.
	 * @return true if exist, false otherwise.
	 */
	public abstract boolean isExistingDirectory(DBDirectory directory);
	
	/**
	 * Check if a directory exist. 
	 * @param directory the full directory path.
	 * @param owner the owner.
	 * @return true if exist, false otherwise.
	 */
	public abstract boolean isExistingDirectory(String directory, String owner);
	
	/**
	 * This method setting the syncronized directory.
	 * @param directory the full directory path.
	 * @throws DataBaseErrorException if error occured in database.
	 */
	public abstract void setSyncDirectory(DBDirectory directory) throws DataBaseErrorException;
	
	/**
	 * This method return a DBDirectory.
	 * @param owner the owner of directory.
	 * @return the syncronization directory.
	 * @throws DataBaseErrorException if error occurred in database.
	 * @throws UserConflictException if user does not exists.
	 */
	public abstract DBDirectory getSyncDirectory(String owner) throws DataBaseErrorException, UserConflictException;
	
	/**
	 * This method return default directory.
	 * @param owner the owner of directory.
	 * @return the default syncronization directory.
	 */
	public abstract DBDirectory getDefaultSyncDirectory(String owner);
}
